package com.sgcc.sx.pmos.e_sx_mall.presenter;

import com.sgcc.sx.pmos.common.base.BasePresenter;
import com.sgcc.sx.pmos.common.http.HttpInterConst;
import com.sgcc.sx.pmos.common.http.HttpRequestUtils;
import com.sgcc.sx.pmos.common.http.MvpNetCallback;
import com.sgcc.sx.pmos.e_sx_mall.bean.OrderCheckResutBean;
import com.sgcc.sx.pmos.e_sx_mall.contract.OrderTimeChoiceContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

public class OrderTimeChoicePresenter extends BasePresenter<OrderTimeChoiceContract.View> implements OrderTimeChoiceContract.Presenter{

    @Override
    public void checkTime(String combId,String startData,String endData,String membersId) {
        Map<String, Object> params = new HashMap<>();
        params.put("combId", combId);
        params.put("startDate", startData);
        params.put("endDate", endData);
        params.put("membersId", membersId);
        params.put("_t", System.currentTimeMillis());

        HttpRequestUtils.getInstance().request(params, HttpInterConst.CHECK_ORDER_TIME, new MvpNetCallback<OrderCheckResutBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                getView().queryTimeCheckFailed();
            }

            @Override
            public void onResponse(OrderCheckResutBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().queryTimeCheckSuccess(response);
            }
        });

    }
}
